//------------------------------------------------------------------------------
// <copyright file="TavernsCollectionComponent.cs" company="Damian Antonowicz">
//       copyright © 2010 Damian Antonowicz
// </copyright>
// <author>Damian Antonowicz</author>
// <email>poczta@damianantonowicz.pl</email>
//------------------------------------------------------------------------------

using DotBeer.Business.Entities;
using DotBeer.Data;
using DotBeer.Business.Components.Exceptions;

namespace DotBeer.Business.Components
{
    public static class TavernsCollectionComponent
    {
        public static void Save(TavernsCollection taverns)
        {
            AbstractDataAccess<TavernsCollection> tavernsCollectionDAL = new TavernsCollectionDataAccess();
            HandleExceptions.BusinessLogicPolicy(() => tavernsCollectionDAL.Save(taverns));
        }

        public static TavernsCollection Load()
        {
            AbstractDataAccess<TavernsCollection> tavernsCollectionDAL = new TavernsCollectionDataAccess();
            TavernsCollection tavernsCollection = null;

            HandleExceptions.BusinessLogicPolicy(() =>
                {
                    tavernsCollection = tavernsCollectionDAL.Load();
                });

            if (tavernsCollection == null)
                tavernsCollection = new TavernsCollection();

            return tavernsCollection;
        }
    }
}
